﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace NetSync.Core
{
    public interface INetConnection : IDisposable
    {
        string Name { get; }

        event EventHandler<ConnectionEventArgs> ConnectionEvent;

        event EventHandler<DispatchEventArgs> DispatchMessageEvent;

        event EventHandler<DispatchErrorEventArgs> DispatchMessageErrorEvent;

        Task InitAsync(NetConfig config, CancellationToken token = default);

        Task PublishAsync(string topic, byte[] data, CancellationToken token = default);

        Task PublishAsync<TData>(string topic, TData data, CancellationToken token = default);

        Task SubscribeAsync(List<SubscribeInfo> subscribeInfos, CancellationToken token = default);

        Task UnsubscribeAsync(List<SubscribeInfo> subscribeInfos, CancellationToken token = default);
    }
}